package com.grandtech.insurance.controller;


import com.grandtech.gmis.common.utils.R;

import com.grandtech.insurance.domain.DkParam;
import com.grandtech.insurance.feign.AgribigdataClient;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/dock")
public class DksjtyController {

    @Autowired
    private AgribigdataClient agribigdataClient;


    @Transactional
    @GetMapping("/getArea")
    public R getArea(
            @RequestParam(defaultValue = "findCmOmDivisionList",required = false) String action,
            @RequestParam(defaultValue = "0001560000000022",required = false) String orgUniqueCd,
            @RequestParam(defaultValue = "2022",required = false) Integer bizYear
    ){
        try {
            String map=agribigdataClient.getCropList(action, orgUniqueCd, bizYear);
            return R.data(map);
        }catch (Exception e){
            e.printStackTrace();
            return R.error(e.getMessage());
        }
    }

    @Transactional
    @PostMapping("/updateDk")
    public R updateDk(@RequestBody List<DkParam> paramList){
        try {
            String map=agribigdataClient.updateDk(paramList);
            return R.data(map);
        }catch (Exception e){
            e.printStackTrace();
            return R.error(e.getMessage());
        }
    }

}


















































